# -*- mode: snippet -*-
# name: color_with_palette
# key: color_with_palette
# --
# This function generates a plot for an
# internal matrix, and takes a palette as
# parameter so that we can display the
# plot using various palettes, as the
# palette should be a function
color_with_palette <- function(palette) {
  x <- y <- seq(-8 * pi, 8 * pi, len = 40)
  r <- sqrt(outer(x^2, y^2, "+"))
  z <- cos(r^2) * exp(-r / (2 * pi))
  filled.contour(
    z,
    axes = FALSE,
    color.palette = palette,
    asp = 1
  )
}